package xyz.csmcool.imserver.mqHander;

import com.rabbitmq.client.Channel;
import org.springframework.messaging.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class MyListener {

    @RabbitListener(queues = "deadQueue")
    public void printMsg(Message message, Channel channel) throws IOException {
        Long deliveryTag = (Long) message.getHeaders().get(AmqpHeaders.DELIVERY_TAG);
        channel.basicAck(deliveryTag, false);
        System.out.println("成功获取死信队列消息：" + message.getPayload());
    }

}
